package com.xiaoju.uemc.tinyid.client.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

/**
 * @author du_imba
 */
@Slf4j
public class PropertiesLoader {
    private PropertiesLoader() {
    }

    public static Properties loadProperties(String location) {
        Properties props = new Properties();
        log.info("Loading properties file from path:" + location);
        try (InputStream resource = PropertiesLoader.class.getClassLoader().getResourceAsStream(location);
             InputStreamReader in = new InputStreamReader(resource, StandardCharsets.UTF_8)) {
            props.load(in);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        return props;
    }
}
